home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / dflat_r_.arc / STATBAR.C < prev    next >
Text File  |  1991-10-02  |  2KB  |  83 lines

  1. /* ---------------- statbar.c -------------- */
  2.  
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <string.h>
  6. #include <ctype.h>
  7. #include <dos.h>
  8. #include "dflat.h"
  9.  
  10. #ifdef INCLUDE_STATUSBAR
  11.  
  12. int StatusBarProc(WINDOW wnd, MESSAGE msg, PARAM p1, PARAM p2)
  13. {
  14.     char *statusbar;
  15.     switch (msg)    {
  16.         case CREATE_WINDOW:
  17.         case MOVE:
  18.             SendMessage(wnd, CAPTURE_CLOCK, 0, 0);
  19.             break;
  20.         case PAINT:    
  21.             if (!isVisible(wnd))
  22.                 break;
  23.             if ((statusbar = calloc(1, WindowWidth(wnd)+1)) == NULL)
  24.                 break;
  25.             memset(statusbar, ' ', WindowWidth(wnd));
  26.             *(statusbar+WindowWidth(wnd)) = '\0';
  27.             strncpy(statusbar+1, "F1=Help", 7);
  28.             if (wnd->text)    {
  29.                 int len = min(strlen(wnd->text), WindowWidth(wnd)-17);
  30.                 if (len > 0)    {
  31.                     int off=(WindowWidth(wnd)-len)/2;
  32.                     strncpy(statusbar+off, wnd->text, len);
  33.                 }
  34.             }
  35. #ifdef INCLUDE_CLOCK
  36.             if (wnd->TimePosted)
  37.                 *(statusbar+WindowWidth(wnd)-8) = '\0';
  38. #endif
  39.             SetStandardColor(wnd);
  40.             ClearAttribute(wnd, NOCLIP);
  41.             clipline(wnd, 0, statusbar);
  42.             wputs(wnd, statusbar, 0, 0);
  43.             free(statusbar);
  44.             AddAttribute(wnd, NOCLIP);
  45.             return TRUE;
  46.         case BORDER:
  47.             return TRUE;
  48. #ifdef INCLUDE_CLOCK
  49.         case CLOCKTICK:    {
  50.             WINDOW wnd1 = Focus.LastWindow;
  51.             int x = GetLeft(wnd)+WindowWidth(wnd)-9;
  52.             while (wnd1 != NULLWND && wnd1 != wnd)    {
  53.                 if (wnd1 != GetParent(wnd))    {
  54.                     if (SendMessage(wnd1, INSIDE_WINDOW, x, GetTop(wnd)))
  55.                         return TRUE;
  56.                     if (SendMessage(wnd1, INSIDE_WINDOW, x+5, GetTop(wnd)))
  57.                         return TRUE;
  58.                 }
  59.                 wnd1 = PrevWindow(wnd1);
  60.             }
  61.             SetStandardColor(wnd);
  62.             wputs(wnd, (char *)p1, WindowWidth(wnd)-8, 0);
  63.             wnd->TimePosted = TRUE;
  64.             return TRUE;
  65.         }
  66. #endif
  67.         case CLOSE_WINDOW:
  68. #ifdef INCLUDE_CLOCK
  69.             SendMessage(NULLWND, RELEASE_CLOCK, 0, 0);
  70. #endif
  71.             if (GetText(wnd) != NULL)    {
  72.                 free(GetText(wnd));
  73.                 GetText(wnd) = NULL;
  74.             }
  75.             break;
  76.         default:
  77.             break;
  78.     }
  79.     return BaseWndProc(STATUSBAR, wnd, msg, p1, p2);
  80. }
  81.  
  82. #endif
  83.